﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ICSharpCode.SharpZipLib.Zip;
using COM.Web;
using ICSharpCode.SharpZipLib.GZip;
using WebApp.Service;
using System.Xml.Linq;

namespace WebApp.Web.Controllers
{
    public class OperateLogController : Controller
    {
        public ActionResult Index()
        {
            return this.RedirectToAction("List");
        }

        public ActionResult Create()
        {
            return View("Edit");
        }

        [HttpPost]
        public ActionResult Create(string createDate, string operateContent, string userInfo)
        {
            var operateLogService = Unity.Instance.GetService<IOperateLogService>();
            var operateXml = new XElement("DevLog",
                                    new XElement("userInfo",userInfo),
                                    new XElement("createDate",createDate),
                                    new XElement("operateContent",operateContent)
                                         );

            operateLogService.Log("开发日志", operateXml.ToString());
            var s = new System.Web.Routing.RouteValueDictionary { { "from", "Create" } };
            return this.RedirectToAction("List",s);
        }

        public ActionResult Success()
        {
            return View();
        }

        public ActionResult List(string from)
        {
            ViewBag.From = from;
            var operateLogService = Unity.Instance.GetService<IOperateLogService>();
            ViewBag.OperateLogList = operateLogService.GetOperateLogList("开发日志");
            return View();
        }
    }
}
